#include "file_operator.h"
#include<cmath>
double acc = 9.8/5156;
double gyr = 1/100.0;
std::vector<imu_data> openfile(const std::string filename)
{
    std::FILE* file;
    file = std::fopen((filename).c_str(), "r");
    std::vector<imu_data> imuList;
    if(file == NULL){
        printf("gg");
        return imuList;
    }
    double acc_x, acc_y, acc_z, gyro_x, gyro_y, gyro_z,a,b,c,a1,b1,c1,a2,b2,c2,a3,b3,c3,a4,b4,c4,a5,b5,c5;
     while (fscanf(file, "%lf       %lf     %lf         %lf        %lf       %lf   %lf    %lf  %lf    %lf  %lf  %lf  %lf   %lf    %lf    %lf  %lf   %lf     %lf    %lf          %lf     %lf     %lf     %lf",  &acc_x, &acc_y, &acc_z,&gyro_x, &gyro_y, &gyro_z,&a,&b,&c,&a1,&b1,&c1,&a2,&b2,&c2,&a3,&b3,&c3,&a4,&b4,&c4,&a5,&b5,&c5) != EOF) {
        imu_data data;
        data.gx = gyro_x*gyr;
        data.gy = gyro_y*gyr;
        data.gz = gyro_z*gyr;

        data.ax = acc_x*acc;
        data.ay = acc_y*acc;
        data.az = acc_z*acc;
        //printf("%lf,%lf,%lf,%lf,%lf,%lf\n",data.gx,data.gy,data.gz,data.ax,data.ay,data.az);
        imuList.push_back(data);               
    }
    std::fclose(file);
    return imuList;  
}